package com.lb.shopguide.ui.dialog;

import android.content.Context;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;

import com.lb.shopguide.R;


/**
 * Created by Administrator on 2017/1/6.
 */

public class DialogMakeSure {
    private Context mContext;

    public DialogMakeSure(Context context) {
        this.mContext = context;
    }

    public AlertDialog getDialog(String content) {
        final AlertDialog dialog = new AlertDialog.Builder(mContext)
                .setMessage(content)
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
//                        mPresenter.deleteTopic(bbsId, topicId);
                        if (mListener != null) {
                            mListener.onSure(dialog, which);
                        }
                    }
                })
                .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        if (mListener != null) {
                            mListener.onCancel(dialog, which);
                        }
                    }
                })
                .create();
        dialog.setOnShowListener(new DialogInterface.OnShowListener() {
            @Override
            public void onShow(DialogInterface arg0) {
                dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(mContext.getResources().getColor(R.color.sg_common_red));
                dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(mContext.getResources().getColor(R.color.sg_black));
            }
        });
        return dialog;
    }

    public interface OnDialogClickListener {
        void onSure(DialogInterface dialog, int which);

        void onCancel(DialogInterface dialog, int which);
    }

    private OnDialogClickListener mListener;

    public void setOnDialogClickListener(OnDialogClickListener listener) {
        this.mListener = listener;
    }
}
